package com.winchain.config;

import com.shell.bee.base.utils.SpringContextUtil;
import com.winchain.chainbill.chain.ChainCallbackService;
import com.winchain.chainbill.chain.callback.CallbackService;
import com.winchain.chainbill.chain.service.impl.ChainCallbackServiceImpl;
import java.util.ArrayList;
import java.util.List;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class CallbackConfig {
	@Bean
	public ChainCallbackService chainCallbackService() {
		String[] beans = { "receivablesImptCallbackService", "receivablesModCallbackService",
				"accessModCallbackService", "billRcvAprvCallbackService", "billSndCallbackService",
				"billRcvCallbackService", "billXfeRevCallbackService", "billDctRevCallbackService",
				"billRpurPmtCallbackService", "assetsMgtCallbackService", "creditAssetMgtCallbackService",
				"assetsMgtReserveCreditCallbackService", "adjAssertCreditCallbackService",
				"adjAssertTransientCallbackService", "recAdjustmentCallbackService", "trdQuotaCallbackService",
				"resQuotaCallbackService", "billDctSerFeeCallbackService", "billAprvRjctCallbackService" };

		List<CallbackService> services = new ArrayList();
		for (String bean : beans) {
			services.add((CallbackService) SpringContextUtil.getBean(bean));
		}
		Object chainCallbackService = new ChainCallbackServiceImpl(services);
		return (ChainCallbackService) chainCallbackService;
	}
}
